<style type="text/css">

</style>
<div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <ol class="breadcrumb" style="position:relative;margin-top:5px;margin-bottom:5px;">
                            <li>
                                <i class="fa fa-cube"></i>  菜单管理
                            </li>
                            <li class="active">材料管理
                            </li>
                            	
                          
                		<div style="position:absolute;right:2%;top:23%;cursor:pointer;">
                			<i class="fa fa-plus-circle fa-lg"  onclick="window.location.href='/ingredient/addinit'"></i>
                		</div>

                        </ol>
                        <div class="table-responsive" >
                         <table class="table table-hover table-striped" style="margin-bottom:10px;">
                        	<tr>
	        <td width="50%"><select class="form-control" name="ingredientType" id="ingredientType">
									  
								            </select></td>
            <td width="50%">   	     <div class="form-group input-group" >
                <input type="text" class="form-control" name="ingredientName" id="ingredientName" value="<%=ingredientName %>">
                <span class="input-group-btn">
                  <button class="btn btn-default" type="button" onclick="javascript:query(1);"><i class="fa fa-search"></i></button>
                </span>
              </div></td>

        </tr>
        </table>
                        </div>
								  
							
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="table-responsive">
                            <table class="table table-hover table-striped">
                                <thead>
                                    <tr>
                                   		 <th>类型</th>
                                        <th>名称</th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody>
<% ingredients.forEach(function(ingredient, index) { %>
	        <tr>
	        <td><i class="fa fa-edit" onClick="window.location.href='/ingredient/editinit?id=<%=ingredient.id %>'" style="cursor:pointer;"></i>&nbsp;<%=ingredient.type.name%></td>
            <td> <%=ingredient.name %></td>
            <td>
            <i class="fa fa-minus-circle" onClick="del('<%=ingredient.id %>')" style="cursor:pointer;"></i> 
          
           </td>
        </tr>


<%}) %>
</tbody>
                            </table>
                        </div>
                    </div>
                </div>
<nav style="text-align:right;">
      <ul class="pagination">
        <li  <% if(page==1||totalPage==0){%>
         class="disabled"><a href="javascript:;" aria-label="Previous">
          <%}else{%>
          ><a href="javascript:query(<%=(page-1)%>)" aria-label="Previous">
           <%}%>
            <span aria-hidden="true">«</span>
          </a>
        </li>
        <% for(var i=1;i<=totalPage;i++){ %>
        	<% if(i==page){%>
        		 <li class="active"><a href="javascript:void"><%=i %></a></li>
        	<%}else{%>
       			 <li><a href="javascript:query(<%=(i)%>)"><%=i %></a></li>
       		<%}%>
        <%} %>   
        <li <% if(page==totalPage||totalPage==0){%>
         class="disabled"><a href="javascript:;" aria-label="Next">
          <%}else{%>
          	> <a href="javascript:query(<%=(parseInt(page)+1)%>)" aria-label="Next">
          <%}%>
            <span aria-hidden="true">»</span>
          </a>
        </li>
      </ul>
    </nav>
            </div>
<script>
	function del(id){
		if(confirm("确认删除该条记录?")){
			window.location.href='/ingredient/del?id='+id;
		}
		return false;
	}

	function query(page){
		var typeId=$("#ingredientType").val();
		var ingredientName=$("#ingredientName").val();
		window.location.href='/ingredient?page='+page+"&typeId="+typeId+"&ingredientName="+ingredientName;
	}
	$("#ingredientType").dsel("/ingredient/itypelist","<%=typeId%>","暂无材料类型",true);
	
</script>